Cursor snapping is a mechanism used in some computer-assisted drawing applications to assist in aligning a user-guided cursor with selected points in a drawing, such as drawing coordinate grid points that coincide with the outlines of various drawing objects. Whether or not the cursor snaps to a particular location is typically determined by a pre-selected tolerance value. Thus, when the cursor comes within a certain distance of a candidate snapping point location, and the distance is less than the snapping tolerance, the cursor is automatically moved from its current location to the snapped location.
Since coordinate grid points may not form a set of convenient snapping locations, some drawing applications operate to snap the cursor location to certain imaginary guide lines. These guide lines are generated at a specified angle with respect to the drawing coordinate system, and intersect selected points in the drawing (e.g., the corners of drawings objects). Thus, when the cursor comes within a certain distance that is less than the snapping tolerance from one of these guide lines, the cursor is snapped to the guide line and the guide line is then displayed in the drawing to give visual feedback to the user.
To process all of the potential guide lines that are within the snapping tolerance of the current cursor location, a clipping rectangle is formed that bounds space around the cursor. All guide lines that pass through all drawing objects are clipped with the clipping rectangle. An immense processing workload due to clipping activity may thus arise, because even those lines that are clearly not within the proximity of the current cursor location may be clipped against the clipping rectangle before being processed and discarded as a guide line that might include a potential snapped location.
The problem may be more easily recognized when a concrete example is considered. Assume that a drawing includes N objects, with each object generating M potential guide lines. As the cursor is moved across the drawing, the drawing application operates to clip M*N lines before determining the next snapped location. Thus, if there are 1000 objects in a drawing, and each object has only three potential guide lines, 3000 lines are clipped against the clipping rectangle as the cursor is moved from point to point. Since snapping is an operation that may be performed every time the user moves the drawing cursor to a new location, the drawing application in this case clips 3000 lines before a decision can be made as to whether to move the cursor to a new snapping location, and if so, to which snapping location. This processing workload exists even when most, or all of the potential guide lines are nowhere near the current cursor location, resulting in a reduced cursor tracking rate and guide line display speed.